<?php
require_once( PHP_PATH . 'common.php' );

$template->welcomeMsg = "Team Report";

$teamId = isset( Url::$pageVars[ 'GETPOST' ][ 'tid' ] ) ? Url::$pageVars[ 'GETPOST' ][ 'tid' ] : 0;
$template->teams = $teams = Utility::getUserTeams( $teamId );
$template->teamClass = '';
if( count( $teams ) == 1 ){
	$teamId = $teams[0][ 'id' ];
	$template->teamClass = "hide";
}elseif( count( $teams ) > 1 && !isset( Url::$pageVars[ 'GETPOST' ][ 'tid' ] ) ){
	$teamId = $teams[0][ 'id' ];
}
$template->viewLink = $teamId > 0 ? "/expenses/nv/tid/$teamId/" : '/expenses/';
$template->report = $teamId > 0 ? ExpenseUtility::getTeamReport( $teamId ) : array();